﻿using HardcoreGame.Common.CustomSets;
using HardcoreGame.Common.GlobalProjectiles;
using HardcoreGame.Content.Items.Ammo.SlingBullets;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.Audio;
using Terraria.DataStructures;
using Terraria.ID;
using Terraria.ModLoader;

namespace HardcoreGame.Content.Items.Weapons.Ranged.Slingshot
{
    public class SpectreSlingshoot : ModItem
    {
        public override void SetStaticDefaults()
        {
            CustomItemSets.Slingshoot[Type] = true;
        }
        public override void SetDefaults()
        {
            Item.DefaultToRangedWeapon(1, ModContent.ItemType<StoneSlingBullet>(), 14, 8.5f, true);
            Item.damage = 85;
            Item.width = Item.height = 26;
            Item.useStyle = ItemUseStyleID.Shoot;
            Item.knockBack = 3f;
            Item.value = 16500;
            Item.rare = ItemRarityID.Yellow;
            Item item = Item;
            SoundStyle item2 = SoundID.Item5;
            item.UseSound = new SoundStyle?(item2.WithPitchOffset(0.2f));
        }
        public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback)
        {
            int shot = Projectile.NewProjectile(source, position.X, position.Y, velocity.X, velocity.Y, type, damage, knockback, player.whoAmI);
            Main.projectile[shot].GetGlobalProjectile<SlingshootProjectile>().spectreSlingshoot = true;
            return false;
        }
        public override Vector2? HoldoutOffset()
        {
            return new Vector2?(new Vector2(-2f, -2f));
        }
        public override void AddRecipes()
        {
            Recipe modRecipe = Recipe.Create(Type, 1);
            modRecipe.AddIngredient(ItemID.SpectreBar, 10);
            modRecipe.AddTile(TileID.MythrilAnvil);
            modRecipe.Register();
        }
    }
}
